package com.example.sys.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.common.vo.Result;
import com.example.sys.entity.Scheduling;
import com.example.sys.service.ISchedulingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wuage
 * @since 2023-12-22
 */
@RestController
@RequestMapping("/scheduling")
public class SchedulingController {

    @Autowired
    private ISchedulingService schedulingService;

    @GetMapping("/all")
    public Result<Map<String, List<Scheduling>>> info(){
        Map<String, List<Scheduling>> listAll = schedulingService.listAll();

        return Result.success(listAll);
    }

    @PostMapping("/addsch")
    public Result addScheduling(@RequestBody Scheduling scheduling){
        schedulingService.save(scheduling);
        return Result.success();
    }

    @DeleteMapping("/deletesch/{id}")
    public Result deleteSchedulingrById(@PathVariable("id") Integer id){
        schedulingService.removeById(id);
        return Result.success();
    }

    @GetMapping("/getsch/{id}")
    public Result<Map<String, List<Scheduling>>> getSchedulingrById(@PathVariable("id") Integer id){
        Map<String, List<Scheduling>> listAll=schedulingService.getSchedulingrById(id);
        return Result.success(listAll);
    }
}
